# @FileName  : photoConf.py
# @Time      : 2021/7/14 0014  17:33
# @Author    : LuZhaoHui
# @Software  : PyCharm

# 读取配置
from core.tool import *

VER = '1.5.1.14'


# var_ssh = {'host': '127.0.0.1', 'port': '22', 'user': 'root', 'pass': 'root'}
# var_tcp = {'host': '127.0.0.1', 'port': '22'}

class photoKey():
    def __init__(self, file):
        self.config = MyParser()
        self.name = CONF_PATH + '/' + file
        saveLog('read photo key [' + self.name + ']')
        self.ScreenKey = []
        self.DevelopKey = []
        self.readKey()

    def getVarToList(self, section, key):
        slist = []
        str = self.getConfig(section, key)
        if len(str) > 0:
            slist = str.split(',')
        return slist

    def getConfig(self, section, key):
        str = ''
        try:
            str = self.config.get(section, key)
        except Exception as e:
            print(e)
        return str

    def isScreenKey(self, key):
        if key == '1234567890':
            return True
        if key in self.ScreenKey:
            return True
        return False

    def isDevelopKey(self, key):
        if key == '1234567890':
            return True
        if key in self.DevelopKey:
            return True
        return False

    def readKey(self):
        self.config.read(self.name, 'utf-8')
        # [SCREEN]
        try:
            self.ScreenKey = self.getVarToList('SCREEN', 'ScreenKey')
        except Exception as e:
            self.ScreenKey = []
        # [DEVELOP]
        try:
            self.DevelopKey = self.getVarToList('DEVELOP', 'DevelopKey')
        except Exception as e:
            self.DevelopKey = []


class photoConfig():
    def __init__(self, file):
        self.initVar()
        self.config = MyParser()
        self.name = CONF_PATH + '/' + file
        saveLog('read photo conf [' + self.name + ']')
        self.readConf()

    def initVar(self):
        # 设计配置
        self.DesignVar = {'Title': '缩微',
                          'WindowSize': [],
                          'TabTitle': []
                          }
        # 缩微服务配置
        self.ScreenVar = {'ScreenName': [],
                          'ScreenAuth': [],
                          'ScreenKey': [],
                          'ScreenIp': [],
                          'ScreenPort': [],
                          'ScreenUser': [],
                          'ScreenPass': [],
                          'ScreenWorkPath': [],
                          'ScreenTcpPort': [],
                          'ScreenReport': [],
                          }

        # 冲洗服务配置
        self.DevelopVar = {'DevelopName': [],
                           'DevelopAuth': [],
                           'DevelopKey': [],
                           'DevelopIp': [],
                           'DevelopPort': [],
                           'DevelopUser': [],
                           'DevelopPass': [],
                           'DevelopWorkPath': [],
                           'DevelopTcpPort': [],
                           'DevelopReport': []
                           }

        # 操作员
        self.OperatorVar = {'OpCode': [],
                            'OpName': [],
                            'OpRole': [],
                            'OpPass': [],
                            'OpRight': [],
                            'OpPermit': []
                            }
        # 语音配置
        self.VoiceVar = {'Open': '',
                         'Begin': '',
                         'End': '',
                         'Link': '',
                         'DevBegin': '',
                         'DevEnd': ''
                         }
        # 下载服务
        self.DownloadVar = {'RemoteThread': 0,
                            'PrintThread': 0
                            }

        # WEB管理服务器
        self.WebVar = {'Ip': '',
                       'SshPort': 22,
                       'User': 'root',
                       'Pass': 'dashen2021',
                       'WorkPath': ''}

        # UPDATE服务器
        self.UpdateVar = {'UpdateTimer': 600,
                          'Ip': '',
                          'SshPort': 22,
                          'User': 'root',
                          'Pass': 'dashen2021',
                          'UpdatePath': '',
                          'UpdateVer': '1.0.0.1',
                          'UpdateSrcPath': '',
                          'UpdateRemark': ''}

        # WREMOTE数据服务器
        self.RemoteVar = {'Ip': '',
                          'SshPort': 22,
                          'User': 'root',
                          'Pass': 'dashen2021',
                          'WorkPath': '',
                          'LocalPath': ''}
        # 外部数据库
        self.MysqlVar = {'Ip': '',
                         'Port': 3306,
                         'User': 'root',
                         'Pass': 'dashen2021',
                         'Database': 'photo',
                         'Queue': 0,
                         'ActDb': 0,
                         'WorkDb': 0}
        # 35MM胶片配置
        self.Photo35Var = {'PhotoLength': 305,
                           'PhotoFullLength': 450,
                           'PhotoHalfLength': 220,
                           'PhotoSpaceLength': 0,
                           'PhotoValidLength': 0,
                           'PhotoFullWidth1': 6300,
                           'PhotoFullHeight1': 4320,
                           'PhotoFullDiffer1': 100,
                           'PhotoHalfWidth1': 3150,
                           'PhotoHalfHeight1': 4320,
                           'PhotoHalfDiffer1': 100,
                           'PhotoFullWidth2': 6300,
                           'PhotoFullHeight2': 4320,
                           'PhotoFullDiffer2': 100,
                           'PhotoHalfWidth2': 3150,
                           'PhotoHalfHeight2': 4320,
                           'PhotoHalfDiffer2': 100,
                           'ScreenMaxBorderWidth1': 6320,
                           'ScreenMaxBorderWidth2': 6320,
                           'ScreenMaxBorderHeight': 4320,
                           'ScreenMaxBorderPosX': 0,
                           'ScreenMaxBorderPosY': 0,
                           'PhotoHeadLength': 7500,
                           'PhotoTailLength': 7500,
                           'PhotoStandardNums': 10,
                           'PhotoStandardType': 0,
                           'PhotoStandardSpace': 2,
                           'PhotoLimitMode': 0,
                           'PhotoMaxFiles': 600,
                           'PhotoFolderSpace': 2,
                           'Name': '35MM',
                           'Suffix': '无,光点',
                           'Dot': 1,
                           'IsHide': 0}

        self.Photo3xVar = {'PhotoLength': 305,
                           'PhotoFullLength': 450,
                           'PhotoHalfLength': 220,
                           'PhotoSpaceLength': 0,
                           'PhotoValidLength': 0,
                           'PhotoFullWidth1': 6300,
                           'PhotoFullHeight1': 4320,
                           'PhotoFullDiffer1': 100,
                           'PhotoHalfWidth1': 3150,
                           'PhotoHalfHeight1': 4320,
                           'PhotoHalfDiffer1': 100,
                           'PhotoFullWidth2': 6300,
                           'PhotoFullHeight2': 4320,
                           'PhotoFullDiffer2': 100,
                           'PhotoHalfWidth2': 3150,
                           'PhotoHalfHeight2': 4320,
                           'PhotoHalfDiffer2': 100,
                           'ScreenMaxBorderWidth1': 6320,
                           'ScreenMaxBorderWidth2': 6320,
                           'ScreenMaxBorderHeight': 4320,
                           'ScreenMaxBorderPosX': 0,
                           'ScreenMaxBorderPosY': 0,
                           'PhotoHeadLength': 7500,
                           'PhotoTailLength': 7500,
                           'PhotoStandardNums': 10,
                           'PhotoStandardType': 0,
                           'PhotoStandardSpace': 2,
                           'PhotoLimitMode': 0,
                           'PhotoMaxFiles': 600,
                           'PhotoFolderSpace': 2,
                           'Name': '3xMM',
                           'Suffix': '无,光点',
                           'Dot': 1,
                           'IsHide': 0}

        # 16MM胶片配置
        self.Photo16Var = {'PhotoLength': 305,
                           'PhotoFullLength': 180,
                           'PhotoHalfLength': 90,
                           'PhotoSpaceLength': 0,
                           'PhotoValidLength': 0,
                           'PhotoFullWidth1': 4200,
                           'PhotoFullHeight1': 2880,
                           'PhotoFullDiffer1': 100,
                           'PhotoHalfWidth1': 2100,
                           'PhotoHalfHeight1': 2880,
                           'PhotoHalfDiffer1': 100,
                           'PhotoFullWidth2': 4200,
                           'PhotoFullHeight2': 2880,
                           'PhotoFullDiffer2': 100,
                           'PhotoHalfWidth2': 2100,
                           'PhotoHalfHeight2': 2880,
                           'PhotoHalfDiffer2': 100,
                           'ScreenMaxBorderWidth1': 6320,
                           'ScreenMaxBorderWidth2': 6320,
                           'ScreenMaxBorderHeight': 4320,
                           'ScreenMaxBorderPosX': 0,
                           'ScreenMaxBorderPosY': 0,
                           'PhotoHeadLength': 7500,
                           'PhotoTailLength': 7500,
                           'PhotoStandardNums': 10,
                           'PhotoStandardType': 0,
                           'PhotoStandardSpace': 2,
                           'PhotoLimitMode': 0,
                           'PhotoMaxFiles': 1600,
                           'PhotoFolderSpace': 2,
                           'Name': '16MM',
                           'Suffix': '无,光点',
                           'Dot': 1,
                           'IsHide': 0}
        # 色阶
        self.ColorScaleVar = {'MaxPixs': 20000000,
                              'LightNums': 25,
                              'LumNums': 10,
                              'LumField': '5, 10, 20, 30, 40, 50, 60, 70, 80, 85',
                              'ExpoRatio': 1.0,
                              'ExpoField': '500, 550, 600, 650, 700, 750, 800, 850, 900, 950',
                              'ScaleNums': 64,
                              'ScalePos': 0,
                              'ScaleWeight0': '0.0',
                              'ScaleWeight1': '0.0',
                              'ScaleWeight2': '0.0',
                              'ScaleWeight3': '0.0',
                              'ScaleWeight4': '0.0',
                              'ScaleWeight5': '0.0',
                              'ScaleWeight6': '0.0',
                              'ScaleWeight7': '0.0',
                              'ScaleWeight8': '0.0',
                              'ScaleWeight9': '0.0',
                              'ScaleWeight10': '0.0',
                              'ScaleWeight11': '0.0',
                              'ScaleWeight12': '0.0',
                              'ScaleWeight13': '0.0',
                              'ScaleWeight14': '0.0',
                              'ScaleWeight15': '0.0',
                              'ScaleWeight16': '0.0',
                              'ScaleWeight17': '0.0',
                              'ScaleWeight18': '0.0',
                              'ScaleWeight19': '0.0',
                              'ScaleWeight20': '0.0',
                              'ScaleWeight21': '0.0',
                              'ScaleWeight22': '0.0',
                              'ScaleWeight23': '0.0',
                              'ScaleWeight24': '0.0',
                              'ScaleWeight25': '0.0',
                              'ScaleWeight26': '0.0',
                              'ScaleWeight27': '0.0',
                              'ScaleWeight28': '0.0',
                              'ScaleWeight29': '0.0',
                              'ScaleWeight30': '0.0',
                              'ScaleWeight31': '0.0',
                              'ScaleWeight32': '0.0',
                              'ScaleWeight33': '0.0',
                              'ScaleWeight34': '0.0',
                              'ScaleWeight35': '0.0',
                              'ScaleWeight36': '0.0',
                              'ScaleWeight37': '0.0',
                              'ScaleWeight38': '0.0',
                              'ScaleWeight39': '0.0',
                              'ScaleWeight40': '0.0',
                              'ScaleWeight41': '0.0',
                              'ScaleWeight42': '0.0',
                              'ScaleWeight43': '0.0',
                              'ScaleWeight44': '0.0',
                              'ScaleWeight45': '0.0',
                              'ScaleWeight46': '0.0',
                              'ScaleWeight47': '0.0',
                              'ScaleWeight48': '0.0',
                              'ScaleWeight49': '0.0',
                              'ScaleWeight50': '0.0',
                              'ScaleWeight51': '0.0',
                              'ScaleWeight52': '0.0',
                              'ScaleWeight53': '0.0',
                              'ScaleWeight54': '0.0',
                              'ScaleWeight55': '0.0',
                              'ScaleWeight56': '0.0',
                              'ScaleWeight57': '0.0',
                              'ScaleWeight58': '0.0',
                              'ScaleWeight59': '0.0',
                              'ScaleWeight60': '0.0',
                              'ScaleWeight61': '0.0',
                              'ScaleWeight62': '0.0',
                              'ScaleWeight63': '0.0',
                              'ScaleWeight64': '0.0',
                              'ScaleWeight65': '0.0',
                              'ScaleWeight66': '0.0',
                              'ScaleWeight67': '0.0',
                              'ScaleWeight68': '0.0',
                              'ScaleWeight69': '0.0',
                              'ScaleWeight70': '0.0',
                              'ScaleWeight71': '0.0',
                              'ScaleWeight72': '0.0',
                              'ScaleWeight73': '0.0',
                              'ScaleWeight74': '0.0',
                              'ScaleWeight75': '0.0',
                              'ScaleWeight76': '0.0',
                              'ScaleWeight77': '0.0',
                              'ScaleWeight78': '0.0',
                              'ScaleWeight79': '0.0',
                              'ScaleWeight80': '0.0',
                              'ScaleWeight81': '0.0',
                              'ScaleWeight82': '0.0',
                              'ScaleWeight83': '0.0',
                              'ScaleWeight84': '0.0',
                              'ScaleWeight85': '0.0',
                              'ScaleWeight86': '0.0',
                              'ScaleWeight87': '0.0',
                              'ScaleWeight88': '0.0',
                              'ScaleWeight89': '0.0',
                              'ScaleWeight90': '0.0',
                              'ScaleWeight91': '0.0',
                              'ScaleWeight92': '0.0',
                              'ScaleWeight93': '0.0',
                              'ScaleWeight94': '0.0',
                              'ScaleWeight95': '0.0',
                              'ScaleWeight96': '0.0',
                              'ScaleWeight97': '0.0',
                              'ScaleWeight98': '0.0',
                              'ScaleWeight99': '0.0',
                              'ScaleWeight100': '0.0',
                              'ScaleWeight101': '0.0',
                              'ScaleWeight102': '0.0',
                              'ScaleWeight103': '0.0',
                              'ScaleWeight104': '0.0',
                              'ScaleWeight105': '0.0',
                              'ScaleWeight106': '0.0',
                              'ScaleWeight107': '0.0',
                              'ScaleWeight108': '0.0',
                              'ScaleWeight109': '0.0',
                              'ScaleWeight110': '0.0',
                              'ScaleWeight111': '0.0',
                              'ScaleWeight112': '0.0',
                              'ScaleWeight113': '0.0',
                              'ScaleWeight114': '0.0',
                              'ScaleWeight115': '0.0',
                              'ScaleWeight116': '0.0',
                              'ScaleWeight117': '0.0',
                              'ScaleWeight118': '0.0',
                              'ScaleWeight119': '0.0',
                              'ScaleWeight120': '0.0',
                              'ScaleWeight121': '0.0',
                              'ScaleWeight122': '0.0',
                              'ScaleWeight123': '0.0',
                              'ScaleWeight124': '0.0',
                              'ScaleWeight125': '0.0',
                              'ScaleWeight126': '0.0',
                              'ScaleWeight127': '0.0'
                              }
        # 分析
        self.AnalyseVar = {'SrcDir': '',
                           'LightThresholdRatio': '1.0',
                           'LightMulti': '3.0'
                           }
        # 生成二维码
        # self.QrcodeCreateVar = {'ImageQrcodeSrcPath': '',
        #                         'ImageQrcodePath': ''
        #                         }
        # 还原二维码
        # self.QrcodeRestoreVar = {'ImageQrcodePath': '',
        #                          'ImageQrcodeDesPath': ''
        #                          }
        # 图片源
        self.ImageVar = {'ImgSrc': 0,
                         'ImgSrcPath': 'work',
                         'ImgSrcDir': 'work',
                         'ImgCacheDir': '',
                         'ImageProcSrcPath': 'src',
                         'ImageProcOutPath': 'out',
                         'SetWorkLstDir': 'work',
                         'ImgPhotoType': 0,
                         'ImgBack': 0,
                         'ImgSpace': 0,
                         'ImgBlackBorder': 0,
                         'ImgEnlarge': 0,
                         'ImgReduce': 0,
                         'ImgHalfWidthScale': 0.8,
                         'ImgHalf': 0,
                         'ImgSplitNums': 0,
                         'ImgSplitLoc': 0,
                         'ImgSplitSpace': 2,
                         'ImgWaterMarkLocation': 3,
                         'ImgWaterMarkSize': 1,
                         'ImgWaterMarkMode': 0
                         }
        # 项目
        self.WorkVar = {'WorkMainDataPath': '',
                        'WorkLocalDataPath': '',
                        'WorkWebMainPos': -1,
                        'WorkWebSubPos': -1
                        }

        # 本地
        self.LocalVar = {'LocalWorkMainPath': '',
                         'LocalWorkSubPath': '',
                         'LocalWorkName': '',
                         'LocalPrintType': 0,
                         'LocalPrintExposure1': 600,
                         'LocalPrintExposure2': 600,
                         'LocalPrintSpaceRange': 2.0
                         }
        # 打印
        self.PrintVar = {'PrintSrcPath': '',
                         'PrintSrcList': '100, 100, 5',
                         'PrintListSort': 0,
                         'PrintListDelay': '100, 600',
                         'PrintWorkName': '',
                         'PrintPhotoType': 0,
                         'PrintGroupPos': 0,
                         'PrintGroupLight1': '0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0',
                         'PrintGroupLight2': '0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0',
                         'PrintGroupExpo': '0,0,0,0,0,0,0,0,0,0',
                         'PrintGroupFlicker': '0,0,0,0,0,0,0,0,0,0'
                         }
        # VAR
        self.CurVar = {'CurTabName': '',
                       'CurIndex': 0,
                       'CurWorkName': 'work',
                       'CurOp': 0,
                       'CurLogRows': 500
                       }

    def getConfig(self, section, key):
        str = ''
        try:
            str = self.config.get(section, key)
        except Exception as e:
            print(e)
            str = None
        return str

    def getVarToList(self, section, key, n):
        slist = []
        str = self.getConfig(section, key)
        if str != None and len(str) > 0:
            slist = str.split(',')
        else:
            if n > 0:
                slist = [''] * n
        return slist

    def readConf(self):
        self.config.read(self.name, 'utf-8')
        # [DESIGN]
        for k in self.DesignVar:
            c = self.getConfig('DESIGN', k)
            if c == None:
                continue
            str = eval(c)
            if isinstance(self.DesignVar[k], int):
                self.DesignVar[k] = int(str)
            elif isinstance(self.DesignVar[k], list):
                self.DesignVar[k] = list(str)
            else:
                self.DesignVar[k] = str

        # [SCREEN]
        n = 0
        for k in self.ScreenVar:
            self.ScreenVar[k] = self.getVarToList('SCREEN', k, n)
            if n == 0:
                n = len(self.ScreenVar[k])

        # [DEVELOP]
        n = 0
        for k in self.DevelopVar:
            self.DevelopVar[k] = self.getVarToList('DEVELOP', k, n)
            if n == 0:
                n = len(self.DevelopVar[k])

        # [OPERATOR]
        n = 0
        for k in self.OperatorVar:
            self.OperatorVar[k] = self.getVarToList('OPERATOR', k, n)
            if n == 0:
                n = len(self.OperatorVar[k])

        # [VOICE]
        for k in self.VoiceVar:
            value = self.getConfig('VOICE', k)
            self.VoiceVar[k] = value

        # [DOWNLOAD]
        try:
            for k in self.DownloadVar:
                value = int(self.getConfig('DOWNLOAD', k))
                self.DownloadVar[k] = value
        except Exception as e:
            print('DOWNLOAD error')
            self.writeConfSetDownload()

        # [Update]
        for k in self.UpdateVar:
            str = self.getConfig('UPDATE', k)
            if str == None:
                self.writeConfSet('UPDATE', k, self.UpdateVar[k])
            else:
                if isinstance(self.UpdateVar[k], int):
                    self.UpdateVar[k] = int(str)
                else:
                    self.UpdateVar[k] = str

        # [WEB]
        for k in self.WebVar:
            str = self.getConfig('WEB', k)
            if str == None:
                continue
            if isinstance(self.WebVar[k], int):
                self.WebVar[k] = int(str)
            else:
                self.WebVar[k] = str
        # [REMOTE]
        for k in self.RemoteVar:
            str = self.getConfig('REMOTE', k)
            if str == None:
                continue
            if isinstance(self.RemoteVar[k], int):
                self.RemoteVar[k] = int(str)
            else:
                self.RemoteVar[k] = str
        # [MYSQL]
        try:
            for k in self.MysqlVar:
                str = self.getConfig('MYSQL', k)
                if isinstance(self.MysqlVar[k], int):
                    self.MysqlVar[k] = int(str)
                else:
                    self.MysqlVar[k] = str
        except Exception as e:
            print('MYSQL error')
            self.writeConfSetMysql()

        # [PHOTO35]
        for k in self.Photo35Var:
            str = self.getConfig('PHOTO35', k)
            if str == None:
                self.writeConfSet('PHOTO35', k, self.Photo35Var[k])
            else:
                if isinstance(self.Photo35Var[k], int):
                    self.Photo35Var[k] = int(str)
                else:
                    self.Photo35Var[k] = str
        # [PHOTO3x]
        for k in self.Photo3xVar:
            str = self.getConfig('PHOTO3x', k)
            if str == None:
                self.writeConfSet('PHOTO3x', k, self.Photo3xVar[k])
            else:
                if isinstance(self.Photo3xVar[k], int):
                    self.Photo3xVar[k] = int(str)
                else:
                    self.Photo3xVar[k] = str
        # [PHOTO16]
        for k in self.Photo16Var:
            str = self.getConfig('PHOTO16', k)
            if str == None:
                self.writeConfSet('PHOTO16', k, self.Photo16Var[k])
            else:
                if isinstance(self.Photo16Var[k], int):
                    self.Photo16Var[k] = int(str)
                else:
                    self.Photo16Var[k] = str
        # [COLORSCALE]
        for k in self.ColorScaleVar:
            str = self.getConfig('COLORSCALE', k)
            if str == None:
                continue
            if isinstance(self.ColorScaleVar[k], int):
                self.ColorScaleVar[k] = int(str)
            else:
                self.ColorScaleVar[k] = str
        # [ANALYSE]
        for k in self.AnalyseVar:
            str = self.getConfig('ANALYSE', k)
            if str == None:
                continue
            if isinstance(self.AnalyseVar[k], int):
                self.AnalyseVar[k] = int(str)
            else:
                self.AnalyseVar[k] = str
        # [IMAGE]
        for k in self.ImageVar:
            str = self.getConfig('IMAGE', k)
            if str == None:
                self.writeConfImage(k, self.ImageVar[k])
                continue
            if isinstance(self.ImageVar[k], int):
                self.ImageVar[k] = int(str)
            else:
                self.ImageVar[k] = str
        # [WORK]
        for k in self.WorkVar:
            str = self.getConfig('WORK', k)
            if str == None:
                continue
            if isinstance(self.WorkVar[k], int):
                self.WorkVar[k] = int(str)
            else:
                self.WorkVar[k] = str
        # [LOCAL]
        for k in self.LocalVar:
            str = self.getConfig('LOCAL', k)
            if str == None:
                continue
            if isinstance(self.LocalVar[k], int):
                self.LocalVar[k] = int(str)
            else:
                self.LocalVar[k] = str
        # [PRINT]
        for k in self.PrintVar:
            str = self.getConfig('PRINT', k)
            if str == None:
                continue
            if isinstance(self.PrintVar[k], int):
                self.PrintVar[k] = int(str)
            else:
                self.PrintVar[k] = str
        #
        for k in self.CurVar:
            str = self.getConfig('VALUE', k)
            if str == None:
                continue
            if isinstance(self.CurVar[k], int):
                self.CurVar[k] = int(str)
            else:
                self.CurVar[k] = str

    def writeConf(self):
        for k in self.CurVar:
            self.config.set('VALUE', k, str(self.CurVar[k]))
        for k in self.ImageVar:
            self.config.set('IMAGE', k, str(self.ImageVar[k]))
        with open(self.name, 'w', encoding='utf-8') as f:
            self.config.write(f)

    def writeConfSetDownload(self):
        for k in self.DownloadVar:
            self.config.set('DOWNLOAD', k, str(self.DownloadVar[k]))
        with open(self.name, 'w', encoding='utf-8') as f:
            self.config.write(f)

    def writeConfSetMysql(self):
        for k in self.MysqlVar:
            self.config.set('MYSQL', k, str(self.MysqlVar[k]))
        with open(self.name, 'w', encoding='utf-8') as f:
            self.config.write(f)

    def writeConfSet(self, set, key, value):
        self.config.set(set, key, str(value))
        with open(self.name, 'w', encoding='utf-8') as f:
            self.config.write(f)

    def writeConfSets(self, set, keys, values):
        for i, key in enumerate(keys):
            self.config.set(set, key, str(values[i]))
        with open(self.name, 'w', encoding='utf-8') as f:
            self.config.write(f)

    def writeConfCurVar(self, key, value):
        self.CurVar[key] = value
        self.config.set('VALUE', key, str(self.CurVar[key]))
        with open(self.name, 'w', encoding='utf-8') as f:
            self.config.write(f)

    def writeConfWork(self, key, value):
        self.WorkVar[key] = value
        self.config.set('WORK', key, str(self.WorkVar[key]))
        with open(self.name, 'w', encoding='utf-8') as f:
            self.config.write(f)

    def writeConfLocal(self, key, value):
        self.LocalVar[key] = value
        self.config.set('LOCAL', key, str(self.LocalVar[key]))
        with open(self.name, 'w', encoding='utf-8') as f:
            self.config.write(f)

    def writeConfPrint(self, key, value):
        self.PrintVar[key] = value
        self.config.set('PRINT', key, str(self.PrintVar[key]))
        with open(self.name, 'w', encoding='utf-8') as f:
            self.config.write(f)

    def writeConfPhoto35(self, kvs):
        for k in kvs:
            self.Photo35Var[k[0]] = k[1]
            self.config.set('PHOTO35', k[0], str(self.Photo35Var[k[0]]))
        with open(self.name, 'w', encoding='utf-8') as f:
            self.config.write(f)

    def writeConfPhoto3x(self, kvs):
        for k in kvs:
            self.Photo3xVar[k[0]] = k[1]
            self.config.set('PHOTO3x', k[0], str(self.Photo3xVar[k[0]]))
        with open(self.name, 'w', encoding='utf-8') as f:
            self.config.write(f)

    def writeConfPhoto16(self, kvs):
        for k in kvs:
            self.Photo16Var[k[0]] = k[1]
            self.config.set('PHOTO16', k[0], str(self.Photo16Var[k[0]]))
        with open(self.name, 'w', encoding='utf-8') as f:
            self.config.write(f)

    def writeConfColorScale(self, key, value):
        self.ColorScaleVar[key] = value
        self.config.set('COLORSCALE', key, str(self.ColorScaleVar[key]))
        with open(self.name, 'w', encoding='utf-8') as f:
            self.config.write(f)

    def writeConfRemote(self, key, value):
        self.RemoteVar[key] = value
        self.config.set('REMOTE', key, str(self.RemoteVar[key]))
        with open(self.name, 'w', encoding='utf-8') as f:
            self.config.write(f)

    def writeConfAnalyse(self, key, value):
        self.AnalyseVar[key] = value
        self.config.set('ANALYSE', key, str(self.AnalyseVar[key]))
        with open(self.name, 'w', encoding='utf-8') as f:
            self.config.write(f)

    def writeConfImage(self, key, value):
        self.ImageVar[key] = value
        self.config.set('IMAGE', key, str(self.ImageVar[key]))
        with open(self.name, 'w', encoding='utf-8') as f:
            self.config.write(f)

    def getTypeWidth(self, type):
        # 获取类型的宽和高
        if type == 0:
            return [self.Photo16Var['PhotoFullWidth1'], self.Photo16Var['PhotoFullWidth2']]
        elif type == 1:
            return [self.Photo35Var['PhotoFullWidth1'], self.Photo35Var['PhotoFullWidth2']]
        else:
            return [self.Photo3xVar['PhotoFullWidth1'], self.Photo3xVar['PhotoFullWidth2']]

    def getTypeWidthHeightList(self):
        # 获取类型的宽和高的列表
        typeList = []
        typeList.append(
            [self.Photo16Var['PhotoFullWidth1'], self.Photo16Var['PhotoFullHeight1']])
        typeList.append(
            [self.Photo35Var['PhotoFullWidth1'], self.Photo35Var['PhotoFullHeight1']])
        typeList.append(
            [self.Photo3xVar['PhotoFullWidth1'], self.Photo3xVar['PhotoFullHeight1']])
        typeList.append(
            [self.Photo16Var['PhotoFullWidth2'], self.Photo16Var['PhotoFullHeight2']])
        typeList.append(
            [self.Photo35Var['PhotoFullWidth2'], self.Photo35Var['PhotoFullHeight2']])
        typeList.append(
            [self.Photo3xVar['PhotoFullWidth2'], self.Photo3xVar['PhotoFullHeight2']])
        return typeList

    def getVoiceOpen(self):
        return self.VoiceVar['Open']

    def getVoiceStr(self, vstr, pos):
        lv = vstr.split(',')
        if 0 <= pos < len(lv):
            return lv[pos]
        return ''

    def getVoiceLink(self, pos):
        return self.getVoiceStr(self.VoiceVar['Link'], pos)

    def getVoiceBegin(self, pos):
        return self.getVoiceStr(self.VoiceVar['Begin'], pos)

    def getVoiceEnd(self, pos):
        return self.getVoiceStr(self.VoiceVar['End'], pos)

    def getVoiceDevBegin(self, pos):
        return self.getVoiceStr(self.VoiceVar['DevBegin'], pos)

    def getVoiceDevEnd(self, pos):
        return self.getVoiceStr(self.VoiceVar['DevEnd'], pos)
